package com.lesson15.strategy;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2020/9/18 19:46
 */
public abstract class Duck
{
    FlyBehavior flyBehavior;

    public Duck()
    {
    }

    public void setFlyBehavior(FlyBehavior flyBehavior)
    {
        this.flyBehavior = flyBehavior;
    }

    public abstract void display();

    public void quack()
    {
        System.out.println("鸭子呱呱叫！！！");
    }

    public void swim()
    {
        System.out.println("鸭子会游泳！！！");
    }

    public void fly()
    {
        if (flyBehavior != null)
        {
            flyBehavior.fly();
        }
    }
}
